package com.zhongyu.controller;

import com.zhongyu.pojo.Permission;
import com.zhongyu.pojo.User;
import com.zhongyu.service.PermissionService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import javax.annotation.Resource;
import java.util.List;

@Controller
public class IndexController {

    @Resource
    private PermissionService permissionService;

   @GetMapping("/index")
    public String index(Model model){
      Subject subject= SecurityUtils.getSubject();
     User user= (User) subject.getPrincipal();//登录人
       Session session=subject.getSession();
       session.setAttribute("loginUser",user);
       List<Permission> list=permissionService.searchMenulist();
       model.addAttribute("menuList",list);
        return "index";

    }
}
